<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,user-scalable=no,minimum-scale=1,initial-scale=1">
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta name="apple-mobile-web-app-status-bar-style" content="black"/>
    <meta name="applicable-device" content="mobile">
    <title>{$info.title}</title>
    <script type="text/javascript" src="__PUBLIC__/js/do.js" charset="utf-8"></script>
    <script type="text/javascript" src="__PUBLIC__/js/moble.js" charset="utf-8"></script>
    <link rel="stylesheet" href="__STATIC__/allwin/unmarket/style.css" />
</head>
<body ontouchstart>
<div id="toobar">
    <div class="info"><span>浏览 {$info.views} 次</span><span>购买 {$order_num} 人</span><span>已奖励 {$award_amout} 元</span></div>
    {if isset($info.music)}
        <div id="music" class="rotate"><audio loop src="{$info.music}" id="media" autoplay="" preload=""></audio></div>
    {/if}
</div>
<div id="content-item">
    <div class="page1"><img src="{$info.img}" /></div>        
    <div class="page2">
        <div class="timelogo"><img src="__STATIC__/allwin/unmarket/overtime.png" /></div>
        <div class="timetitle">距离活动结束</div>
        <div class="endtime">
            {if time() >= $info.end_time}
                已结束,请关注下次活动
            {else}
                {$info.start_time|date="Y-m-d"} 至 {$info.end_time|date="Y-m-d"}
            {/if}
        </div>
    </div>
    <div class="page3">
        {if count($store) > 1}<div class="untitle">商家联盟</div><div class="untips">排名不分先后</div>{else}<div class="untitle">本店介绍</div>{/if}
        <div class="uncontent">
            <ul class="store">
                {foreach $store as $rs}
                <li>
                    <div class="store-img"><a href="{:urls('allwin/unmarket/store',$member_miniapp_id,['id'=>$rs.id,'unid' => $info.id])}"><img src="{$rs.img}"></a></div>
                    <div class="store-name">
                        <p class="h1"><a href="{:urls('allwin/unmarket/store',$member_miniapp_id,['id'=>$rs.id,'unid' => $info.id])}">{$rs.name}</a></p>
                        <p class="h2 tel"><a href="tel:{$rs.telphone}">电话:{$rs.telphone}</a></p>
                        <p class="h2 address"><a href="{:urls('allwin/unmarket/store',$member_miniapp_id,['id'=>$rs.id,'unid' => $info.id])}">{$rs.address}</a></p>
                    </div>
                    <div class="store-text"><a href="{:urls('allwin/unmarket/store',$member_miniapp_id,['id'=>$rs.id,'unid' => $info.id])}">{$rs.content|dehtml|raw}</a></div>
                </li>
                {/foreach}
            </ul>
        </div>
    </div>
    {if $order_num > 0}
    <div class="page3 top">
        <div class="untitle">新订单</div>
        <div class="uncontent bd">
            <ul class="user">
                {foreach $order as $rs}
                <li>
                    <div class="user-img"><img src="{$rs.user.face}"></div>
                    <div class="user-name"><p class="h1">{$rs.user.nickname}</p><p class="h3">已付款：{$rs.price}元</p></div>
                    <div class="time">{$rs.order_time|date="Y-m-d"}</div>
                </li>
                {/foreach}
            </ul>
        </div>
    </div>
    {/if}
    {if count($award) > 0}
    <div class="page3 top">
        <div class="untitle">奖励榜</div>
        <div class="uncontent bd">
            <ul class="user">
                {foreach $award as $rs}
                <li>
                    <div class="user-img"><img src="{$rs.user.face}"></div>
                    <div class="user-name"><p class="h1">{$rs.user.nickname}</p><p class="h2">引荐：{$rs.number}人</p></div>
                    <div class="money">奖励：{$rs.money}元</div>
                </li>
                {/foreach}
            </ul>
        </div>
    </div>
    {/if}
    <div class="page3">
        <div class="untitle">购买须知</div>
        <div class="uncontent notes">{$info.note|dehtml|raw}</div>
    </div>
    <div class="page1">{foreach $info.imgs as $img}<img src="{$img}">{/foreach}</div>   
    <div class="gounmarket">
        <a href="javascript:;" class="weui-btn weui-btn_primary open-popup" data-target="#un_popup">商家创建活动,点击预约</a>
    </div> 
</div>
<!-- 分享 -->
<div id="item-btm" style="display:none"></div>
<div id="share_popup" class="weui-popup__container popup-bottom">
<div class="weui-popup__overlay"></div>
<div class="weui-popup__modal">
    <div class="toolbar">
        <div class="toolbar-inner"><a href="javascript:;" class="picker-button close-popup">关闭</a><h1 class="title">邀请购买</h1></div>
    </div>
    <div class="modal-content">
        <div class="weui-msg">
            <div class="weui-msg__icon-area"><img src="{$share_rcode}" style="width: 10em;"></div>
            <div class="weui-msg__text-area">
                <h2 class="weui-msg__title">分享给好友、发朋友圈或好友扫码</h2>
                <p class="weui-msg__desc">推荐好友下单成功,有奖励</p>
            </div>
            <!-- <div class="weui-msg__opr-area">
                <p class="weui-btn-area"><a href="javascript:;" class="weui-btn weui-btn_primary">生成我的海报</a></p>
            </div> -->
        </div>  
    </div>
</div>
</div>
<!-- 下单 -->
<div id="dopay_popup" class="weui-popup__container popup-bottom">
    <div class="weui-popup__overlay"></div>
    <div class="weui-popup__modal">
        <div class="toolbar">
            <div class="toolbar-inner"><a href="javascript:;" class="picker-button close-popup">关闭</a><h1 class="title">提交报名支付</h1></div>
        </div>
        <div class="modal-content">
            {if time() <= $info.start_time}
                <div class="weui-msg">
                    <div class="weui-msg__icon-area"><img src="{$share_rcode}" style="width: 10em;"></div>
                    <div class="weui-msg__text-area">
                        <h2 class="weui-msg__title">当前活动未开始</h2>
                        <p class="weui-msg__desc">关注公众号,时刻关注活动开始时间</p>
                    </div>
                </div>
            {elseif  time() >= $info.end_time}
                <div class="weui-msg">
                    <div class="weui-msg__text-area">
                        <h2 class="weui-msg__title">当前活动已结束</h2>
                        <p class="weui-msg__desc">关注公众号,关注下次活动信息</p>
                    </div>
                </div>
            {else}
            <form id="ajaxForm" action="{$post_url}" method="post">
                <input type="hidden" name="app" value="{$member_miniapp_id}" />
                <input type="hidden" name="id" value="{$info.id}" />
                <div class="weui-btn-area">
                    <div class="weui-cell">
                        <div class="weui-cell__bd"><input name="telphone" class="weui-input" type="tel" placeholder="手机号" required></div>
                    </div>
                    <div class="weui-cell">
                        <div class="weui-cell__bd"><input name="telname" class="weui-input" type="text" placeholder="您的名字" required></div>
                    </div>
                </div>
                <div class="weui-btn-area"><button type="submit" class="weui-btn weui-btn_warn">提交订单</button></div>
            </form>
            {/if}
        </div>
    </div>
</div>
<div class="slidebar">
<ul>
    <li class="item1"><a href="javascript:;" class="open-popup" data-target="#contact_popup"><span class="icon"><img src="__STATIC__/allwin/unmarket/2.png" alt=""></span><span>联系我们</span></a></li>
    <li class="item2"><a href="{:urls('allwin/unmarket/order',$member_miniapp_id,['id'=>$info.id])}"><span class="icon"><img src="__STATIC__/allwin/unmarket/3.png" alt=""></span><span>我的订单</span></a></li>
    <li class="item3"><a href="javascript:;" class="open-popup" data-target="#un_popup"><span class="icon"><img src="__STATIC__/allwin/unmarket/4.png" alt=""></span><span>加入联盟</span></a></li>
</ul>
</div>
<!-- 联系我们 -->
<div id="contact_popup" class="weui-popup__container popup-bottom">
    <div class="weui-popup__overlay"></div>
    <div class="weui-popup__modal">
        <div class="toolbar"><div class="toolbar-inner"><a href="javascript:;" class="picker-button close-popup">关闭</a><h1 class="title">联系客服</h1></div></div>
        <div class="modal-content">
            <div class="weui-msg">
                <div class="weui-msg__icon-area"><img src="{$info.mycode}" style="width: 10em;"></div>
                <div class="weui-msg__text-area">
                    <h2 class="weui-msg__title">电话:{$info.telphone}</h2>
                    <p class="weui-msg__desc">{$info.tips}</p>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- 加入联盟 -->
<div id="un_popup" class="weui-popup__container popup-bottom">
    <div class="weui-popup__overlay"></div>
    <div class="weui-popup__modal">
        <div class="toolbar"><div class="toolbar-inner"><a href="javascript:;" class="picker-button close-popup">关闭</a><h1 class="title">加入联盟</h1></div></div>
        <div class="modal-content">
            <form id="serviceForm" action="{:urls('allwin/unmarket/service',$member_miniapp_id)}" method="post">
                <input type="hidden" name="app" value="{$member_miniapp_id}" />
                <input type="hidden" name="union_id" value="{$info.id}" />
                <div class="weui-btn-area">
                    <div class="weui-cell"><div class="weui-cell__bd"><input name="storename" class="weui-input" type="text" placeholder="商家名称" required></div></div>
                    <div class="weui-cell"><div class="weui-cell__bd"><input name="telphone" class="weui-input" type="tel" placeholder="联系电话" required></div></div>
                    <div class="weui-cell"><div class="weui-cell__bd"><input name="telname" class="weui-input" type="text" placeholder="您的名字" required></div></div>
                </div>
                <div class="weui-btn-area"><button type="submit" class="weui-btn weui-btn_primary">提交联系信息</button></div>
            </form>
        </div>
    </div>
</div>
<!-- 购物栏 -->
<script id="btm_tpl" type="text/html">
    <div class="btn btn-gray"><a href="javascript:;" class="open-popup" data-target="#share_popup"><span>分享推荐</span></a></div>
    <div class="btn"><a href="javascript:;" class="open-popup" data-target="#dopay_popup"><span>立即支付</span></a></div>
</script>
<script type="text/javascript">
Do('weui','fastclick','jweixin','jform','tpl','slide',function(){
    $(function(){
        FastClick.attach(document.body);
    });
    wx.config({$weconfig|raw});
    wx.ready(function (){
        wx.onMenuShareTimeline({title:'{$info.title}',link:'{$share_url|raw}',imgUrl: '{$info.share_img}',success:function(){}});
        wx.onMenuShareAppMessage({title:'{$info.title}',desc:'{$info.share_text}',link:'{$share_url|raw}',imgUrl:'{$info.share_img}',type:'',dataUrl:'',success: function(){}});
    })
    var music = document.getElementById("media"); 
    $("#music").click(function(){
        $(this).toggleClass("rotate");
        if($(this).hasClass("rotate")){music.play();}else{music.pause();}
    })
    $(".top").slide({mainCell:".bd ul",autoPlay:true,effect:"topMarquee",vis:6,interTime:50,trigger:"click"});
    $("#item-btm").show();
    $("#item-btm").html(template("btm_tpl"))
    //提交订单
    var options = {dataType: "json",success:function (rel) {
        $.closePopup();
        if(200 == rel.code){
            var wechat = rel.data;
            wx.chooseWXPay({"timestamp":wechat.timestamp,"nonceStr":wechat.nonceStr,"package":wechat.package,"signType":wechat.signType,"paySign":wechat.paySign,
                success:function (res){
                    $.alert('活动报名成功',function() {
                        window.location.reload()
                    });
                },
            })
        }else{
            $.alert(rel.msg);
        }
    }};
    $('#ajaxForm').ajaxForm(options);
    $('#serviceForm').ajaxForm({dataType: "json",success:function (rel) {
        $.closePopup();
        if(200 == rel.code){
            $.alert(rel.msg, function() {
                window.location.reload()
            });
        }else{
            $.alert(rel.msg);
        }
    }});
});
</script>
</body>
</html>